from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.

class User(AbstractUser):

    mobile = models.CharField('手机号',max_length=13)


class Address(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField('收货人', max_length=12)
    tel = models.CharField('电话', max_length=20)
    street = models.CharField('详细地址', max_length=200)

    def get_address(self):
        """将收货信息拼接成一个字符串"""
        return f"收货人：{self.name},电话:{self.tel},地址:{self.street}"


class CheckIn(models.Model):
    user = models.OneToOneField(User)
    datetime = models.DateTimeField('上次签到时间', default=None, null=True)
    count = models.IntegerField('连续签到次数', default=0)